/**
 * Created by george on 1/18/17.
 */

var Schema = mongoose.Schema;

var parkingMongoSchema = new Schema({
    isValid: {type: Boolean, default: true},
    createdBy: String,                          // 微信 openid
    dateCreated: {type: Date, default: Date.now},
    dateLastModified: {type: Date, default: Date.now},
    community: {type: Schema.Types.ObjectId, ref: 'community'},
    pName: {type: String, default: ""},         // 位置名称
    pAddress: {type: String, default: ""},      // 位置
    category: {type: String, enum: ['求租', '出租']},   //类型
    location: {                                 // GPS
        longitude: Number,
        latitude: Number
    },

    wechatUserInfo: {
        nickName: String,
        gender: Number,
        language: String,
        city: String,
        province: String,
        country: String,
        avatarUrl: String,
        rawData: String,
        signature: String,
        encryptedData: String,
        iv: String
    },

    price: {type: Number, default: 0},          //asking price
    phone: String,

    dateExpired: Date,
    browseCount: {type: Number, default: 0}
});

mongoose.model('parking', parkingMongoSchema, 'parking');